package com.util;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
/**
 * Created by zhangzhuang on 2018/9/17.
 */
public class CommonUtils {
    public static Map<Long, String> sortMapByKey(Map<Long, String> map) {
        if (map == null || map.isEmpty()) {
            return null;
        }

        Map<Long, String> sortMap = new TreeMap<Long, String>(
                new Comparator<Long>(){
                    @Override
                    public int compare(Long o1, Long o2) {
                        // TODO Auto-generated method stub
                        return o1.compareTo(o2);
                    }
                });

        sortMap.putAll(map);

        return sortMap;
    }
}
